﻿using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.Finance;
using NP.BPMReportPlatform.Todo.Dto;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.Finance
{
    /// <summary>
    /// 财务接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/finance")]
    public class FinanceController : BPMReportPlatformController
    {
        private readonly IFinanceService _financeService;

        public FinanceController(IFinanceService financeService)
        {
            _financeService = financeService;
        }

        /// <summary>
        /// 保理平台ukey及账户申请流程 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("FactoringPlatform/GetAllAsync")]
        public async Task<PagedResultDto<GetFactoringPlatformOutput>> GetAllAsync([FromBody] GetFactoringPlatformInput input)
        {
            return await _financeService.GetAllAsync(input);
        }

        /// <summary>
        /// 保理平台ukey及账户申请流程导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("FactoringPlatform/ExportAsync")]
        public async Task<XlsxFileResult<GetFactoringPlatformOutput>> ExportAsync([FromBody] GetFactoringPlatformInput input)
        {
            var rst = await _financeService.ExportAsync(input);
            return new XlsxFileResult<GetFactoringPlatformOutput>(rst, "导出Excel");
        }

        /// <summary>
        ///CBS代办 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("todo/cbs/GetAllAsync")]
        public async Task<PagedResultDto<ItemsItem>> GetAllAsync([FromBody] GetTodoInput input)
        {
            return await _financeService.GetAllAsync(input);
        }

        /// <summary>
        /// 客户应收余额调整申请流程 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("KHYSYETZ/GetAllAsync")]
        public async Task<PagedResultDto<GetKHYSYETZOutput>> GetAllAsync([FromBody] GetKHYSYETZInput input)
        {
            return await _financeService.GetAllAsync(input);
        }

        /// <summary>
        /// 保客户应收余额调整申请流程  导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("KHYSYETZ/ExportAsync")]
        public async Task<XlsxFileResult<GetKHYSYETZOutput>> ExportAsync([FromBody] GetKHYSYETZInput input)
        {
            var rst = await _financeService.ExportAsync(input);
            return new XlsxFileResult<GetKHYSYETZOutput>(rst, "导出Excel");
        }
    }
}